﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WxVote.aspx.cs" Inherits="ZLCMS.Web.Interface.weixin.Html.WxVote" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>微信投票</title>
    <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
    <link href="/Interface/jqm/css/jquery.mobile-1.4.0.min.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .barbox
        {
            height: 18px;
            line-height: 18px;
            overflow: hidden;
            font-size: 12px;
            vertical-align: middle;
        }
        .barbox div
        {
            float: left;
            font-size: 14px;
            width: 112px;
            text-align: right;
        }
        .barbox div a
        {
            color: #0048CC;
        }
        .barbox div
        {
            float: left;
        }
        .barbox div.last
        {
            color: #999;
        }
        .barbox div.barline
        {
            width: 160px;
            background: #E3E3E3;
            height: 12px;
            overflow: hidden;
            margin: 3px 10px 0 10px;
            display: inline;
            border-bottom: solid 1px #F4F4F4;
            border-right: solid 1px #F4F4F4;
        }
        .barbox div.barline div.progressbar
        {
            height: 10px;
            overflow: hidden;
            background: url(/SystemManage/javascripts/progressbar/pbar/barbg.gif) repeat-x;
        }
        .barbox div.barline div.progressbar.barred
        {
            background-position: 0 0;
            border: 1px solid #C2142C;
        }
        .barbox div.barline div.progressbar.baryellow
        {
            background-position: 0 -10px;
            border: 1px solid #EFA804;
        }
        .barbox div.barline div.progressbar.barblue
        {
            background-position: 0 -20px;
            border: 1px solid #0A83E6;
        }
    </style>
    <script src="/Interface/jqm/js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="/Interface/jqm/js/jquery.mobile-1.4.0.min.js" type="text/javascript"></script>
    <script src="/Wap/lib/command/Command.js" type="text/javascript"></script>
    <script src="/Wap/lib/jquery/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function showDialogPage(title, content) {
            $('#dialogPage').find('div[data-role=header] h2').html(title);
            $('#dialogPage').find('div.ui-content p').html(content);
            $("#dialogPage").popup("open");
        }

        function submitVote() {
            var voteItem;
            $("#div_vote_item").find('input').each(function () {
                if ($(this)[0].checked == true) {
                    voteItem = $(this).val();
                }
            });
            if (voteItem == null) {
                showDialogPage("提示","请选择选项");
                return;
            }
            $("#SubmitVote").executeCommand({
                successCallBack: function (result) {
                    showDialogPage("提示", '投票成功');
                    setTimeout(function(){location.reload();},1000);
                },
                errorCallback: function (errorCode, msg) {
                    showDialogPage("提示", msg);
                }
            }, 'SubmitVoteEx', { WxId: '<%=Request["openid"]  %>', VoteId: '<%=Request["uid"]  %>', OwnerAccount: '<%=Request["account"] %>', VoteItem: voteItem });
        }
        <%if(!string.IsNullOrEmpty(ErrorMsg)){ %>
        $(document).ready(function(){
        setTimeout(function(){
         showDialogPage('提示', '<%=ErrorMsg %>');
        }, 1000);
       
        })
        <%} %>

        function animate() {
            $(".progressbar").each(function (i, item) {
                $(item).addClass('barblue');
                var a = $(item).attr("w");
                $(item).animate({
                    width: $(item).attr("w") + "%"
                }, 1000);
            });
        }
      
        $(function(){
          animate();
        });
    </script>
</head>
<body>
    <div data-role="page" id="mypage" data-title='<%= ZLCMS.Business.Util.ParamKit.GetValue("SystemConfig", "SiteName", "&nbsp") %>'>
        <div data-role="header" data-position='fixed'>
            <h1>
                微信投票<%--<%=VotedItem%>--%></h1>
                  <% if (_voteDb.RuleTimes >_totalCount)
                     { %>
            <button class="ui-btn-right ui-btn ui-btn-b ui-btn-inline ui-mini ui-corner-all ui-btn-icon-right ui-icon-check"
                onclick="submitVote()">
                提交</button>
                <%} %>
        </div>
        <div data-role="main">
            <form id="SubmitVote" command='SubmitVote' method="post">
            <div data-role="content">
                <%--   <%if (_voteLog != null){ %><p style="color:red">您已参与过本次投票活动！</p><%} %> --%>
                <p>
                    <%= _voteDb == null ? "" : _voteDb.Content%></p>
                <div data-role="fieldcontain" id="div_vote_item" data-role="controlgroup" command-param='VoteItem'>
                    <asp:Repeater ID="Repeater1" runat="server">
                        <ItemTemplate>
                            <div class="ui-corner-all custom-corners" style="margin-bottom: 10px">
                                <div class="ui-bar-a">
                                    <label for="rdo_<%#Eval("Id") %>">
                                        <%#Container.ItemIndex + 1 %>.<%#Eval("Title") %>
                                    </label>
                                    <input type="radio" name="favcolor" id="rdo_<%#Eval("Id") %>" value='<%#Eval("Id") %>'
                                        <%=  _voteDb.RuleTimes >_totalCount?"":"disabled='disabled'" %>>
                                </div>
                                <div class="ui-body ui-body-a" onclick="$('#rdo_<%#Eval("Id") %>').click()">
                                    <p>
                                        <%#Eval("Content") %></p>
                                </div>
                            </div>
                            <% if (_voteDb.RuleTimes <= _totalCount)
                               { %>
                            <p>
                                <div class="barbox" >
                                    <div class="barline" >
                                        <div divindex="3" id="chartSlide_3" w="<%# _count == 0 ? "1" : (GetVoteCounter(Eval("Id")) * 100 / _count).ToString("0.00")%>"
                                            style="width: 0px;" class="progressbar">
                                        </div>
                                    </div>
                                   
                                        <%# _count == 0 ? "0" : (GetVoteCounter(Eval("Id")) * 100 / _count).ToString("0.00")%>%
                                   
                                </div>
                            </p>
                            <%} %>
                        </ItemTemplate>
                    </asp:Repeater>
                    <input command-param='WxId' type="hidden" value='<%=Request["openid"]  %>' />
                    <input command-param='VoteId' type="hidden" value='<%=Request["uid"]  %>' />
                    <input command-param='OwnerAccount' type="hidden" value='<%=Request["account"] %>' />
                </div>
            </div>
            <div>
            </div>
            </form>
            <div data-role="popup" id="dialogPage" data-dismissible="false" style="max-width: 400px;
                min-width: 250px;" data-overlay-theme="b">
                <div data-role="header" data-theme="a">
                    <h2>
                        提示</h2>
                    <a href="#" class="ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-right"
                        role="button" data-rel="back">关闭</a>
                </div>
                <div role="main" class="ui-content">
                    <p style="text-align: center">
                    </p>
                    <a href="#" data-role="button" class="ui-btn ui-btn-b ui-corner-all ui-icon-check"
                        data-rel="back">确定</a>
                </div>
            </div>
            <div data-role="footer" data-position='fixed'>
                <h1>
                    <%=ZLCMS.Business.Util.ModuleKit.HtmlModuleData("Footer",null) %></h1>
            </div>
        </div>
</body>
</html>
